{extend name="layout/layout"}
{block name="content"}
<main class="user_page  ">
    <section class="">
        <div class="layui-main">
            <div class="user_con">
                <div class="user_headpage" data-load="user_active_header">
                    {include file="user_activity/page_menu" menu='refund' id="$id" /}
                </div>
                <div class="right_main ">
                    <div class="active_w active3 ">
                        <p class="text-align-center ft18 mb16 ft-bold">請選擇退款方式</p>
                        <p class="text-align-center ft14 gary_c9 mb50 ft-bold">為保護消費者權益，當任何活動票券售出時無法變更退費方式，請您謹慎選擇。</p>
                        <from class="layui-form refund-form {if isset($refund.refund_type) && $refund.refund_type == 1} active {/if}" lay-filter="refund_form">
                            <div class="content">
                                <ul class="layui-row layui-col-space30 ul_height active_ul a13_ul1">
                                    <li class="layui-col-md12 layui-col-xs12">
                                        <div class="item {if isset($refund.refund_type) && $refund.refund_type == 1} active {/if}" " data-type="1">
                                            <div class="b1">
                                                <p class="t1">委托ACCUPASS退款</p>
                                                <i class="layui-icon layui-icon-success orange_c"></i>
                                            </div>
                                            <div class="b2">如期舉辦的活動，如委託 ACCUPASS 代辦退款事宜，報名人需註冊並登入 ACCUPASS 申辦退票，且將向申辦人收取
                                            </div>
                                        </div>
                                    </li>
                                    <li class="layui-col-md12 layui-col-xs12">
                                        <div class="item {if isset($refund.refund_type) && $refund.refund_type == 2} active {/if}"  data-type="2">
                                            <div class="b1">
                                                <p class="t1">自行退款</p>
                                                <i class="layui-icon layui-icon-success orange_c"></i>
                                            </div>
                                            <div class="b2">
                                                <p class="mb30">請填妥以下資訊方便消費者與您取得聯繫</p>
                                                <div style="max-width:6rem">
                                                    <div class="layui-form-item">
                                                        <div class="label must">聯絡窗口
                                                        </div>
                                                        <div class="">
                                                            <input type="text" name="self_windows" lay-verify="required"
                                                                placeholder="請填寫主辦單位" value="{$refund.self_windows|default=''}" autocomplete="off"
                                                                class="layui-input self_windows">
                                                        </div>
                                                    </div>
                                                    <div class="layui-form-item">
                                                        <div class="label must">聯絡方式
                                                        </div>
                                                        <div class="">
                                                            <input type="text" name="self_contact" lay-verify="required"
                                                                placeholder="请填写聯絡方式" value="{$refund.self_contact|default=''}" autocomplete="off"
                                                                class="layui-input self_contact">
                                                        </div>
                                                    </div>
                                                    <div class="layui-form-item">
                                                        <div class="label must">退款方式說明
                                                        </div>
                                                        <div class="">
                                                            <input type="text" name="self_desc" lay-verify="required"
                                                                placeholder="请填写退款方式說明" value="{$refund.self_desc|default=''}" autocomplete="off"
                                                                class="layui-input self_desc">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </li>
                                    <li class="layui-col-md12 layui-col-xs12">
                                        <div class="item {if isset($refund.refund_type) && $refund.refund_type == 3} active {/if}" data-type="3">
                                            <div class="b1">
                                                <p class="t1">不接受退款</p>
                                                <i class="layui-icon layui-icon-success orange_c"></i>
                                            </div>
                                            <div class="b2">本活動票券一旦售出恕不退款</div>
                                        </div>
                                    </li>
                                </ul>
        
                            </div>
                            <div class="mt40 d-flex jc-s al-c">
                                <button class="layui-btn layui-btn-lg w100 layui-bg-orange next-btn"
                                        onclick="save()">储存
                                </button>
                            </div>
                        </from>
                    </div>
                </div>
            </div>
        </div>
    </section>
</main>


<script>
     function save() {
        var form_data = {};
        var refundType = $('.refund-form .item.active').data('type');
        if(!refundType){
            layui.layer.msg('请选择退款方式', {icon: 2})
            return ;
        }
      
 
        if(refundType == 2){
            var form_data = layui.form.val("refund_form");
            if(form_data.self_contact == '' || form_data.self_desc == '' || form_data.self_windows == ''){
                layui.layer.msg('请完善表单信息', {icon: 2})
                return ;
            }
        }
        form_data.refund_type = refundType;
        $.quickPost('/activity/user/activity/{$act.id}/refund', form_data).done(res => {
           
        });
    }

    
</script>

{/block}
